<?php
if (!class_exists('ConnectionManager') || Configure::read('debug') < 2) {
	return false;
}
$noLogs = !isset($logs);
if ($noLogs){
	$sources = ConnectionManager::sourceList();

	$logs = array();
	foreach ($sources as $source){
		$db = ConnectionManager::getDataSource($source);
		if (!method_exists($db, 'getLog')){
			continue;
		}
		$logs[$source] = $db->getLog();
	}
}

if ($noLogs || isset($_forced_from_dbo_)){
	foreach ($logs as $source => $logInfo){
		$text = $logInfo['count'] > 1 ? 'queries' : 'query';
		printf('<caption>(%s) %s %s took %s ms</caption>', $source, $logInfo['count'], $text, $logInfo['time']);
	}
}
?>